package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0011.java
 * @Author : WangRuoyu
 * @Date 2023/11/29 15:49
 */

public class Q0011 {
    public int maxArea(int[] height) {
        int i = 0;
        int j = height.length - 1;
        int res = 0;
        while (i < j) {
            res = Math.max(res, (j - i) * Math.min(height[i], height[j]));
            if (height[i] < height[j]) i++;
            else j--;
        }
        return res;
    }

    public static void main(String[] args) {
        Q0011 sl = new Q0011();
        int[] height = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        System.out.println(sl.maxArea(height));
    }
}